/* ClientAception.java 
* Created on Dec 20, 2012 
* Author:Mr.Viet
* Phone: 01683430426
* Email: phamvanvietcdhd@gmail.com
*/ 
package com.session9; 

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ClientAception extends Thread {
	private ServerSocket server;
	public boolean running;
	
	public ClientAception(ServerSocket server) {
		this.server = server;
	}
	
	@Override
	public void run() {
		while(running){
			try {
				Socket client = this.server.accept();
				System.out.println("Have a client connected...");
				//Sau Khi nhan ket noi tu phia client thi mo mot tai lang nghe cac message gui tu client do
				ServerTai tai = new ServerTai(client);
				tai.start();
				//Gui 1 message hello client
				tai.sendMessage("Hello Client!");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}
	
}
